<template>
  <!-- 上传文件 -->
  <van-uploader
    type="image"
    :accept="accept"
    multiple
    :after-read="afterRead"
    :before-read="beforeRead"
  >
    <van-button class="icons_button"><van-icon size="25" name="link-o" /></van-button>
  </van-uploader>
</template>
<script setup lang='ts'>
import { showToast } from 'vant'
defineProps({
  accept: {
    type: String,
    default: '.doc,.docx,.xlsx,.xls,.pptx,.ppt,.pdf,.mp3,.mp4,.mov,.avi,.zip,.rar',
  },
})
const beforeRead = (file) => {
  // console.log(file.type, 890)
  if (
    file.type == 'image/jpeg' ||
    file.type == 'image/jpeg' ||
    file.type == 'image/png' ||
    file.type == 'image/gif' ||
    file.type == 'image/bmp' ||
    file.type == 'image/jpg'
  ) {
    showToast('不能上传图片格式')
    return false
  }
  // return true
}
const afterRead = (file) => {
  file.status = 'uploading'
  file.message = '上传中...'

  // setTimeout(() => {
  //   file.status = 'failed'
  //   file.message = '上传失败'
  // }, 1000)
}
</script>
<style scoped lang='scss'>
.icons_button {
  // margin-bottom: 5px;
  width: 35px;
  height: 35px;
  background-color: #eee;
  margin-right: 5px;
}
</style>